home *** CD-ROM | disk | FTP | other *** search
/ Apple WWDC 1996 / WWDC96_1996 (CD).toast / Technology Materials / QuickTime VR / MacOS / QuickDraw™ 3D 1.0.6F4 SDK / Samples / SampleCode / CustomAttribute / ReadMe - Custom Attributes < prev   
Encoding:
Text File  |  1995-11-15  |  5.2 KB  |  69 lines  |  [TEXT/ttxt]

  1.  QuickDraw 3D – Custom Attributes
  2.  
  3. This simple application makes use of custom attributes.  Open the 3DMF files in this folder to get an idea of how this works.
  4.  
  5. The code for the following custom attributes is supplied:
  6.  
  7. name
  8. scale 
  9. up vector
  10. forward direction
  11. W3 anchor
  12. W3 inline
  13.  
  14. The function RegisterAllCustomAttributes() in CustomAttribute_Lib.c registers all the types (and you should also call UnregisterAllCustomAttributes when exiting).
  15.  
  16. You want to look at the functions AdjustCamera and FindAndDisplayCustomAttributes, both in CustomAttributesSupport.c, for examples on how to use the attributes.  How you integrate these attributes in your application is very application specific.  Regard this code as an example.  In this sample, I deal with the upVector, forwardDirection, and scale when reading the models in.  I deal with the name and URL attributes when the user selects the object.
  17.  
  18. Note that for the upVector and forwardDirection the code is not dealing with the case where the current up direction/view direction is the negation of the model's vectors.  The code is based on vector dot and cross products, which produce the same result for vectors that are colinear and vectors that are colinear, but with opposing directions.  See AdjustCamera() for more information.
  19.  
  20. Description
  21.  
  22. name
  23. This element contains a string object.  It can be attached to any object within the Shape hierarchy.  It can also be attached to an attribute set and assigned to a geometry and/or faces.  Note that in future releases we will have other subclasses to the String class, allowing you to use non-ASCII characters.
  24.             Container (
  25.                 NameAttribute ( )
  26.                 CString ( "1 meter box" )
  27.             )
  28.  
  29. scale
  30. This element is of type double.  It determines the relation between 1 unit in the model and 1 meter.  For example, if 1 unit in my model is the equivalent to 10 meters, the scale should be set to 10.
  31. This element should only be attached to groups or geometry objects.  If you add objects that have a scale attribute to a group,  make sure that the objects are transformed (objects are placed in a group with a transform and then added to the main group) so that the scale for the group is uniform. Traversal by applications should be top down. This means that if the scale element is found on a group, there is no need to traverse the objects within the group.
  32.             Container (
  33.                 ScaleAttribute ( 1.0 )
  34.             )
  35.  
  36. up vector
  37. This element is of type TQ3Vector3D.  It specifies the up vector for a model.
  38. This element should only be attached to groups or geometry objects.  If you encapsulate objects that have up vector elements within a group,  make sure that the objects are transformed (objects are placed in a group with a transform and then added to the main group) so that the up vector for the group is uniform. Traversal by applications should be top down. This means that if the upVector element is found on a group, there is no need to traverse the objects within the group.
  39.             Container (
  40.                 UpVector ( 0.0 1.0 0.0)
  41.             )
  42.  
  43. forward direction
  44. This element is of type TQ3Vector3D.  It specifies the forward direction for a model.
  45. This element should only be attached to groups or geometry objects.  If you encapsulate objects that have up vector elements within a group,  make sure that the objects are transformed (objects are placed in a group with a transform and then added to the main group) so that the forward direction for the group is uniform. Traversal by applications should be top down. This means that if the forwadDirection element is found on a group, there is no need to traverse the objects within the group.
  46.             Container (
  47.                 ForwardDirection ( 1.0 0.0 0.5)
  48.             )
  49.  
  50. W3 Anchor
  51. This element contains an URL (universal resource locator) in the form of an C string (ASCII only), an option field, which can be set to kURLReferenceOptionUseMap (meaning that the application should attach a point to the URL before sending the URL to the server), and a string object to encapsulate the description of the site pointed to by the URL (note that this allows for non-ASCII descriptions in the future).
  52. This element should only be attached to groups or geometry objects. Traversal by applications should be top down. This means that if the element is found on a group, there is no need to traverse the objects within the group.
  53.              Container (
  54.                 W3Anchor ("http://www.info.apple.com" 0)
  55.                     CString ( "Apple's home page"
  56.                     )
  57.             )
  58.  
  59. W3 Inline
  60. This element contains an URL (universal resource locator) in the form of an C string (ASCII only).
  61. This element should only be attached to groups or geometry objects. The group or geometry that this element is attached to acts as a proxy for the data pointer to by the URL. This allows the application to perform the URL data retrieval on a separate thread or in the background, or delay the operation until the user expresses interest on the proxy.  Once the URL data is retreived, the data should replace the object that holds the element.  Traversal by applications should be top down. This means that if the element is found on a group, there is no need to traverse the objects within the group.
  62.              Container (
  63.                 W3Inline ("http:www.info.apple.com")
  64.             )
  65.  
  66. Pablo Fernicola
  67. pff@eworld.com
  68. if you are a registered developer, contact Developer Support
  69. DEVSUPPORT@applelink.apple.com